#ifndef __PLATFORM_LIB_CRC_H__
#define __PLATFORM_LIB_CRC_H__
#ifdef __cplusplus
extern "C"
{
#endif

#include "pf_common.h"

/******************************************************************************************************/

typedef struct pf_crc16 pf_crc16_t;

typedef struct pf_crc32 pf_crc32_t;

/*********************************************************************************************
Function Name:  pf_crc16_start
Description  :  Init and get init struct
Inputs       :
Outputs      :  pf_crc16_t*            : return the initial struct of crc16,
                                              NULL for error
ErrorCodes   :  PF_ENOMEM                   : intial crc16 struct error
History      :
---------------------------------------------------------------------------------------------
Author                 Date                          Comments
huyq                   2011-06-25                    create
**********************************************************************************************/
extern pf_crc16_t*  pf_crc16_start(void);

/*********************************************************************************************
Function Name:  pf_crc16_append
Description  :  Append data to pf_crc_16
Inputs       :  pf_crc16_t* crc        : the context of crc16
                const void* data            : the buffer of handle
                int32_t len                 : the len of the buffer
Outputs      :  int                         : 0 for ok
ErrorCodes   :
History      :
---------------------------------------------------------------------------------------------
Author                 Date                          Comments
huyq                   2011-06-25                    create
**********************************************************************************************/
extern int pf_crc16_append(pf_crc16_t* crc, const void* data, int32_t len);

/*********************************************************************************************
Function Name:  pf_crc16_finish
Description  :  Finish and get crc16
Inputs       :  pf_crc16_t* crc             : the context of the crc16
Outputs      :  uint16_t                    : the return value of crc16
ErrorCodes   :
History      :
---------------------------------------------------------------------------------------------
Author                 Date                          Comments
huyq                   2011-06-25                    create
**********************************************************************************************/
extern uint16_t  pf_crc16_finish(pf_crc16_t* crc);

/*********************************************************************************************
Function Name:  pf_crc32_start
Description  :  Init and return 0
Inputs       :
Outputs      :  pf_crc32_t*                 : the intail context of crc32,NULL for error
ErrorCodes   :  PF_ENOMEM                   : intial crc32 struct error
History      :
---------------------------------------------------------------------------------------------
Author                 Date                          Comments
huyq                   2011-06-25                    create
**********************************************************************************************/
extern pf_crc32_t*  pf_crc32_start(void);

/*********************************************************************************************
Function Name:  pf_crc32_append
Description  :  Append data to pf_crc_32
Inputs       :  pf_crc32_t* crc             : the context of the crc32
                const void* data            : the buffer to handle
                int32_t     len             : the len of the buffer
Outputs      :  int                         : 0 for ok
ErrorCodes   :
History      :
---------------------------------------------------------------------------------------------
Author                 Date                          Comments
huyq                   2011-06-25                    create
**********************************************************************************************/
extern int pf_crc32_append(pf_crc32_t* crc, const void* data, int32_t len);

/*********************************************************************************************
Function Name:  pf_crc32_finish
Description  :  Finish and get crc32
Inputs       :  pf_crc32_t* crc             : the crc32 context
Outputs      :  uint32_t                    : the result of the crc32
ErrorCodes   :
History      :
---------------------------------------------------------------------------------------------
Author                 Date                          Comments
huyq                   2011-06-25                    create
**********************************************************************************************/
extern uint32_t  pf_crc32_finish(pf_crc32_t* crc);

/******************************************************************************************************/

#ifdef __cplusplus
}
#endif
#endif /* #ifndef __PLATFORM_LIB_CRC_H__ */


